<div class="layui-card">
  <div class="layui-card-body" style="border-bottom: 1px solid #f6f6f6;">
	  <div class="layui-row">
		  <div class="layui-btn-group larry-group">
              <button class="layui-btn layui-btn-sm layui-btn-danger ajaxPost" url="<{:url('userbank/del')}>">
                  <i class="layui-icon"></i><cite>删除</cite>
              </button>

          </div>
	  </div>
  </div>
  <div class="layui-card-body">
      <div class="layui-row layui-form" id="form">
         <div class="layui-col-lg2">
             <input type="text" name="ukeyword" placeholder="请输入姓名/电话" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-col-lg2">
             <input type="text" name="ubkeyword" placeholder="请输入卡号/开户行" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-col-lg2">
            <select name="is_default">
                <option value="">请选择是否默认</option>
                <{volist name=":c('type.is_default')" id='v'}>
              <option value="<{$key}>"><{$v}></option>
                <{/volist}>
            </select>
        </div>
        <div class="layui-col-lg2">
            <select name="status">
                <option value="">请选择状态</option>
                <{volist name=":c('type.bank_status')" id='v'}>
              <option value="<{$key}>"><{$v}></option>
                <{/volist}>
            </select>
        </div>
        <div class="layui-col-lg1">
          <button class="layui-btn layui-btn-normal" onclick="search()">搜索</button>
        </div>
      </div>
      <div class="layui-row">
              <table class="layui-hide" lay-filter="table" id="table"></table>
      </div>
  </div>
</div>

<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
layui.use(['table','form','larry'], function(){
    var form = layui.form;
    var table = layui.table;
    var $ = layui.$;
    var larry = layui.larry;
    form.render('select');
    search = function(){
        var url = "/userbank/lists";
        var data = $("#form").find("[name]");
        var where = {};
        data.each(function(i,e){
            where[$(e).attr('name')] = $(e).val();
        });
        table.render({
            elem: '#table'
            ,url:url
            ,where:where
            ,method:'post'
            ,cellMinWidth:120
            ,page: true
            ,cols: [[
                {type:'checkbox'},
                {field:'id', title: 'ID',width:80, sort: true,title:'ID'}
                ,{field:'avatar', title: '头像',templet: function(d){
                    return "<img height=30 src='"+d.pic+"' />";
                  }}
                ,{field:'username', title: '姓名'}
                ,{field:'uphone', title: '手机号'}

                ,{field:'bank_no',  title: '卡号',width:200}
                ,{field:'bank_name',  title: '开户行',}
                ,{field:'bank_pro',  title: '开户省',}
                ,{field:'bank_city',  title: '开户市',}
                ,{field:'bank_county',  title: '开户区',}


                ,{field:'is_default',  title: '是否默认'}
                ,{field:'status',  title: '状态'}
                ,{field:'create_time', title: '时间'}
                ,{field:'action', title: '操作',width:178, align:'right', toolbar: '#barDemo',fixed:"right",}
            ]]
        });
    };
    search();
      //监听工具条
      table.on('tool(table)', function(obj){
        var data = obj.data;
        if(obj.event === 'detail'){
            layer.open({
                title:'查看',
                type:2,
                area: ['100%', '100%'],
                content:'/userbank/detail/id/'+data.id
            });
        } else if(obj.event === 'edit'){
          layer.open({
              title:'编辑',
              type:2,
              area: ['100%', '100%'],
              content:'/userbank/edit/id/'+data.id
          });
        } else if(obj.event === 'del'){
          layer.confirm('确认要删除吗?', function(index){
            $.ajax({
                url:"/userbank/del",
                method:"post",
                dataType:"json",
                data:{id:data.id},
                success:function(res){
                    larry.my.action(res);
                    layer.close(index);
                }
            });
          });
        }
      });
});
</script>
